﻿using System;
using LtccApi.Models;
using Microsoft.AspNetCore.Mvc;
using System.Linq;
using System.Collections.Generic;
using Newtonsoft.Json;

namespace LtccApi.Controllers
{
    /// <summary>
    /// Car type controller.
    /// </summary>
    [Route("api/[controller]")]
    [ApiController]
    public class CarTypeController : Controller
    {
        private LtccContext mLtccContext;
        /// <summary>
        /// Initializes a new instance of the <see cref="T:LtccApi.Controllers.CarTypeController"/> class.
        /// </summary>
        /// <param name="ltccContext">Ltcc context.</param>
        public CarTypeController(LtccContext ltccContext)
        {
            mLtccContext = ltccContext;
        }

        /// <summary>
        /// 轿车型号列表
        /// </summary>
        /// <returns>The list.</returns>
        /// <param name="id">序号.</param>
        [HttpGet("{id}")]
        public IActionResult List(int? id)
        {
            List<CarType> carTypes = mLtccContext.CarTypes.Where(m => m.CarBrandID == id).ToList();
            return Ok(carTypes);
        }

    }
}
